<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class user_model extends CI_Model{

	function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
	function get_user_by_id($id)
	{
		$query = $this->db->get_where('users', array('id' => $id), 1);
		$result =  $query->row();
		if(!$result)
		{
			$query = $this->db->get_where('awbteacher', array('id' => $id), 1);
			$result =  $query->row();
			if($result)
			{
				$result->username = $result->TEACHER_NAME;
			}
		}
		return $result;
	}
	function get_user_by_username($username)
	{ 
		$query = $this->db->get_where('users', array('username' => $username), 1);
		$result =  $query->row();
		if(!$result)
		{
			$query = $this->db->get_where('awbteacher', array('TEACHER_NAME' => $id), 1);
			$result =  $query->row();
			if($result)
			{
				$result->username = $result->TEACHER_NAME;
			}
		}
		return $result;
	}
	function update_old_session_by_id($id, $user)
	{
		$this->db->where('id', $id);
		$this->db->update('users', $user); 
	}
	
	
}

?>